﻿using UnityEngine;
using System.Collections;

public class IngameButtonAction : MonoBehaviour {
	public string buttonName;
	public string nextButtonName;
	private AudioClip buttonSuccess, buttonFail;

	public void Start() {
		buttonSuccess = (AudioClip)Resources.Load("Sounds/ButtonUse");
		buttonFail = (AudioClip)Resources.Load("Sounds/ButtonDeny");
		Debug.Log(buttonFail);
	}

	public void playSound(string buttonName) {
		if(buttonName == this.buttonName) {
			GetComponent<AudioSource>().PlayOneShot(buttonSuccess);
		} else {
			GetComponent<AudioSource>().PlayOneShot(buttonFail);
		}
	}

	public virtual void doAction() {

	}

	public string Action(string buttonName) {
		playSound(buttonName);
		if(buttonName != this.buttonName)
			return buttonName;

		doAction();

		return nextButtonName;
	}
}
